#include "words.h"

using namespace std;

/** @fn     char charsimplify(char x)
    @brief      convert all incoming uppercase characters to lowercase
        @param  x   the character to be changed
        @return case-changed char
    */
char charSimplify(char x){
    //check chars within certain range
    if((x >= 0x41 ) && (x <= 0x5A)){
        //if(DEBUG){printf("\ncharacter:\t\tCase-change %c (0x%X) to %c (0x%X)", x, x, x+32, x+32);}
        return(x+32);
    }else{
        return(x);
    }
}

/** @fn     int wordCompare(char *string1, int len1, char *string2, int len2){
    @param  string1 pointer to first string
    @param  len1    length of string1
    @param  string2 pointer to second string
    @param  len2    length of string2
    @brief  compares two words on alfabetical rank
	@return return 1 for decreasing inalphabetic order, -1 for increasing alphabetical order
    */
int wordCompare(char* string1, char* string2){
    if((string1 == (char *) NULL) || (string2 == (char *) NULL)){throw "invalid input for word comparison";}
    if(DEBUG>2){cout << "compare " << hex<<string1 << " to " << hex<<string2 << endl;}
    return(strcmp(string1, string2));
}
